"""
GSM Extension System

This package provides the core extension infrastructure for the GCR Solver Manager,
allowing dynamic loading and management of solver framework extensions.
"""

from .base_extension import BaseExtension
from .base_builder import BaseBuilder, BuildResult
from .base_runner import BaseRunner, ExecutionResult
from .base_validator import BaseValidator
from .extension_registry import ExtensionRegistry
from .extension_loader import ExtensionLoader
from .extension_router import ExtensionRouter
from .config_parser import ExtensionConfigParser, ExtensionDescriptor, BuildStep, TestStep, ValidationRule
from .config_driven_extension import ConfigDrivenExtension
from .config_driven_builder import ConfigDrivenBuilder
from .config_driven_runner import ConfigDrivenRunner, TestResult
from .config_driven_validator import ConfigDrivenValidator, ValidationResult

# Global instances
_registry = None
_router = None
_loader = None
_initialized = False

def initialize_extensions():
    """Initialize the extension system."""
    global _registry, _router, _loader, _initialized
    
    if _initialized:
        return
    
    # Initialize registry, router, and loader
    _registry = ExtensionRegistry()
    _router = ExtensionRouter()
    _loader = ExtensionLoader()
    _initialized = True

def get_registry() -> ExtensionRegistry:
    """Get the extension registry instance."""
    global _registry
    
    if _registry is None:
        initialize_extensions()
    
    return _registry

def get_router() -> ExtensionRouter:
    """Get the extension router instance.""" 
    global _router
    
    if _router is None:
        initialize_extensions()
        
    return _router

def get_loader() -> ExtensionLoader:
    """Get the extension loader instance."""
    global _loader
    
    if _loader is None:
        initialize_extensions()
        
    return _loader

__all__ = [
    'BaseExtension',
    'BaseBuilder',
    'BaseRunner',
    'BaseValidator',
    'ExtensionRegistry',
    'ExtensionLoader',
    'ExtensionRouter',
    'BuildResult',
    'ExecutionResult',
    'ExtensionConfigParser',
    'ExtensionDescriptor',
    'BuildStep',
    'TestStep',
    'ValidationRule',
    'ConfigDrivenExtension',
    'ConfigDrivenBuilder',
    'ConfigDrivenRunner',
    'ConfigDrivenValidator',
    'TestResult',
    'ValidationResult',
    'initialize_extensions',
    'get_registry', 
    'get_router',
    'get_loader',
]

__version__ = '1.0.0'